package com.aglhz.nature.view;

import java.util.List;



import com.aglhz.base.BaseActivity;
import com.aglhz.nature.R;
import com.aglhz.nature.ListView.MyListView;
import com.aglhz.nature.adapter.SecondClassificationAdapter;
import com.aglhz.nature.modle.item.classification.SecondClassificationListData;
import com.aglhz.nature.presenter.SecondClassificationPresenter;
import com.aglhz.nature.view.iv.SecondClassificationView;

import butterknife.Bind;
import butterknife.ButterKnife;




import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class SecondClassificationActivity extends BaseActivity implements SecondClassificationView{
	private String Urlid;
	private SecondClassificationPresenter presenter;
	private SecondClassificationAdapter adapter;
//	private ListView listView;
	@Bind(R.id.second_classification_listview)
	ListView listView;
	private LinearLayout error_bg;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
	
		super.onCreate(savedInstanceState);
		setContentView(R.layout.second_classification);
		setActionBarTitle("商品列表");
//		listView=(ListView) findViewById(R.id.second_classification_listview);
		 ButterKnife.bind(this);
		 error_bg=(LinearLayout) findViewById(R.id.error_bg);
//		Bundle bundle = this.getIntent().getExtras(); 
//		Intent intent =new Intent();
//		intent.getExtras();
//		Log.e("bundle","bundle"+bundle);
		Intent intent =getIntent();
		Urlid = intent.getStringExtra("mcp");
		Log.e("mcp",Urlid);
		presenter = new SecondClassificationPresenter(this);
		// basePresenter register
		presenter.register();
		presenter.loadData();
		
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
		// basePresenter unregister
		presenter.unregister();
	}
	
	
	@Override
	public String setUrlId() {
	
		return Urlid;
	}

	@Override
	public void setAdapter(List<SecondClassificationListData> data) {
		adapter = new SecondClassificationAdapter(data,SecondClassificationActivity.this );
		listView.setAdapter(adapter);
		
	}

	@Override
	public void showErrorView() {
		listView.setVisibility(View.GONE);
		error_bg.setVisibility(View.VISIBLE);
	}

}
